public class code3 {
    public int findNumberOfLIS(int[] nums) {
        int n = nums.length;

        int[] len = new int[n];
        int[] count = new int[n];

        for(int i=0;i<n;i++) len[i]=count[i]=1;

        int retlen = 1,retcount=1;
        for(int i=1;i<n;i++) {
            for(int j=0;j<i;j++) {
                if(nums[j]<nums[i]) {
                    if(len[j]+1==len[i]) //计数
                        count[i]+=count[j];
                    else if(len[j]+1>len[i]) {//重新计数
                        len[i]=len[j]+1;
                        count[i]=count[j];
                    }
                }
            }
            if(retlen==len[i]) retcount+=count[i];
            else if(retlen<len[i]) {
                retlen = len[i];
                retcount = count[i];
            }
        }
        return retcount;
    }
}
